const { Button, Input, Form, Space } = antd;
const { useState } = React;

/**
 * NovelInspiration - 小说创作灵感组件
 * 提供多个AI工具快捷访问和网文创作提示词功能
 */
export default function NovelInspiration(props) {
  // 打开URL函数
  const openUrl = (url) => {
    window.open(url, '_blank');
  };

  // 复制网文构思提示词到剪贴板
  const copyNovelPrompt = () => {
    const prompt = $.prompt_novel_inspiration;
    
    // 复制到剪贴板
    if (typeof $ !== 'undefined' && $.copyToClipboard) {
      $.copyToClipboard(prompt);
    } else {
      // 备用复制方法
      navigator.clipboard.writeText(prompt).then(() => {
        console.log('提示词已复制到剪贴板');
      }).catch(err => {
        console.error('复制失败:', err);
      });
    }
  };

  // 复制网文补充信息到剪贴板
  const copyNovelInfo = () => {
    const prompt = $.prompt_novel_supplement;
    
    // 复制到剪贴板
    if (typeof $ !== 'undefined' && $.copyToClipboard) {
      $.copyToClipboard(prompt);
    } else {
      // 备用复制方法
      navigator.clipboard.writeText(prompt).then(() => {
        console.log('提示词已复制到剪贴板');
      }).catch(err => {
        console.error('复制失败:', err);
      });
    }
  };

  return (
    <div style={{ padding: '16px' }}>
      <Space direction="vertical" size="middle" style={{ width: '100%' }}>
        {/* AI工具按钮组 */}
        <Space wrap>
          <Button type="primary" onClick={() => openUrl('https://www.kimi.com/')}>
            kimi
          </Button>
          <Button type="primary" onClick={() => openUrl('https://chat.deepseek.com/')}>
            deepseek
          </Button>
          <Button type="primary" onClick={() => openUrl('https://metaso.cn/')}>
            metaso
          </Button>
          <Button type="primary" onClick={() => openUrl('https://bot.n.cn/chathome')}>
            nami
          </Button>
          <Button type="primary" onClick={() => openUrl('https://chat.qwen.ai/')}>
            qianwen
          </Button>
          <Button type="primary" onClick={() => openUrl('https://doubao.com/')}>
            豆包
          </Button>
          <Button type="primary" onClick={() => openUrl('https://www.coze.cn/')}>
            coze
          </Button>
          <Button type="primary" onClick={copyNovelPrompt}>
            网文构思
          </Button>
          <Button type="primary" onClick={copyNovelInfo}>
            网文补充信息
          </Button>
        </Space>

        {/* 表单区域 */}
        <Form
          layout="vertical"
          style={{ maxWidth: '600px' }}
        >
          <Form.Item label="小说标题">
            <Input placeholder="请输入小说标题" />
          </Form.Item>
          <Form.Item label="小说类型">
            <Input placeholder="请输入小说类型" />
          </Form.Item>
          <Form.Item label="创作想法">
            <Input.TextArea 
              placeholder="请输入您的创作想法或故事梗概"
              rows={4}
            />
          </Form.Item>
        </Form>
      </Space>
    </div>
  );
}